// 轮播效果
var mySwiper = new Swiper ('.swiper', {
    autoplay:true,  //自动轮播
    loop: true, // 循环模式选项
    
    // 分页器
    pagination: {
      el: '.swiper-pagination',
      clickable :true,
    },
    
    // 前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
    
})


// API交互效果
let APIclassLi=document.querySelectorAll('.APIclass-lei li')
APIclassLi.forEach(function(dom,i){
  dom.addEventListener('mouseover',function(){
    //console.log(this.querySelector('img'))
    this.querySelector('img').src=`../images/api0${i+1}-c.svg`
    this.style.background='#1271ef'
  })
  dom.addEventListener('mouseout',function(){
    //console.log(this.querySelector('img'))
    this.querySelector('img').src=`../images/api0${i+1}.svg`
    this.style.background='#fff'
  })
})


//助力行业巨头,跑马灯动态
let cheatCenter=document.querySelectorAll('.cheat-center')
let index=0;
let cheatMain=document.querySelector('.cheat-main')

let timeId=setInterval(function(){
  //console.log(1)
  hourse()
},2000)
//移入停止,移出执行
cheatMain.addEventListener('mouseover',function(){
  clearInterval(timeId)
})
cheatMain.addEventListener('mouseout',function(){
  timeId=setInterval(function(){
    hourse()
  },2000)
})
function hourse(){
  cheatCenter[index].classList.remove('opc')
  ++index;
  if(index== cheatCenter.length) index=0
  cheatCenter[index].classList.add('opc')
}


//返回顶部
//按钮显示
let rTop = document.querySelector("#returnTop");
//console.log(rTop);
window.addEventListener("scroll", function () {
    if (window.scrollY >= 500) {
        //console.log(1)
        rTop.style.display = "block"
    } else {
      //console.log(2)
      rTop.style.display = "none"

    }
})
//点击返回顶部
let TimeId = null; //计时器为空
rTop.addEventListener("click", function () {
    let sTop = window.scrollY;  //将浏览器高度赋值给sTop
    window.clearInterval(TimeId); 
    TimeId = window.setInterval(function () {
      sTop -= 30;  //高度自减
        if (sTop <= 0) {
          sTop = 0;
            window.clearInterval(TimeId) //清空计时器
        }
        window.scrollTo(0, sTop); //返回到高度为0处

    }, 10)
})

